package com.dz.file.design;


import com.dz.file.design.event.ImageFileServiceImpl;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName : FileContext
 * @Description :
 * @Author : ming
 * @Date: 2020-12-01 11:06
 **/
public class FileContext {
    private static Map<String,FileService> map=new HashMap<>();
    static {
        map.put("png",new ImageFileServiceImpl());
        map.put("jpg",new ImageFileServiceImpl());
        map.put("gif",new ImageFileServiceImpl());
    }
    private FileService fileService;
    public FileContext(String type){
        if(map.containsKey(type)){
            fileService=map.get(type);
        }
    }
    public String upload(String objectName, InputStream stream){
        return fileService.upload(objectName,stream);
    }

}
